package com.wyx.suanfa;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class findDisappearedNumbers {
    public static void main(String[] args) {
        int[] nums = new int[]{4,3,2,7,8,2,3,1};
        int n = nums.length;
        for (int num : nums) {
            int x = (num - 1) % n;
            if(nums[x] <= n){
                nums[x] += n;
            }
        }
        List<Integer> ret = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            if (nums[i] <= n) {
                ret.add(i + 1);
            }
        }
    }
}
/*
* class Solution {
     public List<Integer> findDisappearedNumbers(int[] nums) {
        int n = nums.length;
        for (int num : nums) {
            int x = (num - 1) % n;
            nums[x] += n;
        }
        List<Integer> ret = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            if (nums[i] <= n) {
                ret.add(i + 1);
            }
        }
        return ret;
    }
}*/

/*
 class Solution {
     public List<Integer> findDisappearedNumbers(int[] nums) {
        int n = nums.length;
        Set<Integer> set = new HashSet<>();
        List<Integer> list = new ArrayList<>();
        for(int num : nums){
            set.add(num);
        }
        for(int i = 1;i<=n;i++){
            if(!set.contains(i)){
                list.add(i);
            }
        }
        return list;
         }
}
* */
